Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the suite.rc flow.cylc symlink #4506

Merged
merged 13 commits into from
Dec 3, 2021

Conversation

datamel
Copy link
Contributor

@datamel datamel commented Nov 10, 2021

Removes the flow.cylc symlink created when using a suite.rc file. This also enabled a refactor of duplicate logic from #4497.
These changes close #4500

Milestone is 8.0rc1 to give time for any unforeseen problems to surface.

Requirements check-list

  • I have read CONTRIBUTING.md and added my name as a Code Contributor.
  • Contains logically grouped changes (else tidy your branch by rebase).
  • Does not contain off-topic changes (use other PRs for other changes).
  • Applied any dependency changes to both setup.py and
    conda-environment.yml.
  • Already covered by existing tests (removed now redundant tests).
  • Appropriate change log entry included.
  • No documentation update required (I can not find reference in the docs to this symlink being created).

@datamel datamel added the small label Nov 10, 2021
@datamel datamel added this to the cylc-8.0rc1 milestone Nov 10, 2021
@datamel datamel self-assigned this Nov 10, 2021
@@ -1700,11 +1699,13 @@ def get_run_dir_info(

def detect_both_flow_and_suite(path):
"""Detects if both suite.rc and flow.cylc are in directory.

Permits flow.cylc to be a symlink.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this desirable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@oliver-sanders, I believe you said we should not stop users from manually making a symlink.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check that the symlink points to the right suite.rc, and raise an error if not?

Copy link
Contributor Author

@datamel datamel Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is a flow.cylc there it will use that, regardless of if there is a suite.rc file there. Do we want to forbid users from symlinking other places? I can't think of a reason to forbid, I am probably missing something! I think so long as it is a valid workflow (which will be picked up with other checks) then do we really care how they are sourcing the workflow, it is a bit messy but that is the user's choice?

Copy link
Member

@MetRonnie MetRonnie Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds reasonable to me that users could have a flow.cylc that is a symlink to either its neighbour suite.rc or somewhere else. But if they have a flow.cylc that symlinks to somewhere else and a suite.rc in there, that sounds to me like it should fail in the same way as a normal flow.cylc file and a suite.rc in there.

TLDR:

ok_but_a_bit_dodgy
`-- flow.cylc -> ~/something.cylc

ok
|-- flow.cylc -> suite.rc  # or flow.cylc -> ~/cylc-run/ok/suite.rc?
`-- suite.rc

bad
|-- flow.cylc -> ~/something.cylc
`-- suite.rc

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Resolving this as there is a use case (at the MO) for users to source workflow from outside the run directory.

Copy link
Member

@MetRonnie MetRonnie Nov 16, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry Mel, not sure if you saw my latest comment above #4506 (comment). I think it is similar to what Oliver said (except he said we don't have to worry about the middle case)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I didn't see that, thanks @MetRonnie, mustn't have refreshed the page before posting.

Copy link
Member

@wxtim wxtim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Read -looks sensible.
  • Played with.

I had one question about the functionality - do we want to allow the symlink to pass?

CHANGES.md Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
@@ -1700,11 +1699,13 @@ def get_run_dir_info(

def detect_both_flow_and_suite(path):
"""Detects if both suite.rc and flow.cylc are in directory.

Permits flow.cylc to be a symlink.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we check that the symlink points to the right suite.rc, and raise an error if not?

cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
tests/functional/cylc-install/00-simple.t Show resolved Hide resolved
cylc/flow/workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
if log_msg:
assert log_msg in caplog.messages
def test_is_forbidden_symlink_returns_false_for_non_symlink(tmp_path):
"""Test sending a non symlink path is not marked as forbidden"""
Copy link
Member

@MetRonnie MetRonnie Nov 26, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't a lone symlink also be not marked as forbidden?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks @MetRonnie. Small adjustment and test added. I hope all bases are covered this time!

@datamel datamel force-pushed the remove-suite-flow-symlink branch 2 times, most recently from 88ca3aa to e366a38 Compare November 29, 2021 13:49
Comment on lines 1792 to 1793
link = flow_file.resolve()
if link.parent == flow_file.parent:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would allow

myflow
|-- something.cylc
|-- flow.cylc -> something.cylc
`-- suite.rc

which is equivalent to having distinct flow.cylc and suite.rc files in the same run dir.

Perhaps it should be something like

if flow_file.resolve() == flow_file.parent / WorkflowFiles.SUITE_RC:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This case (I think) is covered by the following condition: if flow_file.parent.joinpath(WorkflowFiles.SUITE_RC).exists():.

Copy link
Member

@MetRonnie MetRonnie Dec 1, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be, but it will return False before getting to that.

See my suggestion: https://github.com/cylc/cylc-flow/pull/4506/files#r760191324

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for my confusion! All testing for me was raising the error....
image
The return False does not return before that (where it should!) because flow_file.parent needed a resolve() on the end to hit the false.
Will go with your suggestion (adding a resolve()), thanks @MetRonnie

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, coming back to this (confusion after your suggestion was added by Tim so it wasn't visible to me). This suggestion will forbid symlinking elsewhere.
Going to push a change which I think now covers all scenarios, based on your if flow_file.resolve() == flow_file.parent / WorkflowFiles.SUITE_RC: suggestion.

tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
tests/unit/test_workflow_files.py Outdated Show resolved Hide resolved
datamel and others added 4 commits November 30, 2021 09:53
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>
@datamel
Copy link
Contributor Author

datamel commented Dec 1, 2021

@wxtim I've made some logic changes since your approval, sorry! So requesting re-review.

@datamel datamel requested a review from wxtim December 1, 2021 09:32
Co-authored-by: Ronnie Dutta <61982285+MetRonnie@users.noreply.github.com>

if log_msg:
assert log_msg in caplog.messages
def test_is_forbidden_symlink_returns_false_for_non_symlink(tmp_path):
Copy link
Member

@wxtim wxtim Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we test some scenarios where is_forbiddenTrue?
Apart from Codecov highlighting it, I would expect there to be ~2 (sets of/parameters?) tests for a function returning a boolean.

Copy link
Contributor Author

@datamel datamel Dec 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are currently 2 tests covering this scenario, is forbidden → True. I think that the two that are there are sufficient but let me know if you'd like more added. I'll have a look at why the codecov thinks otherwise.

Copy link
Member

@MetRonnie MetRonnie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code could probably be refactored to simplify it, but that can wait.

@wxtim wxtim merged commit 06d78c2 into cylc:master Dec 3, 2021
@datamel datamel deleted the remove-suite-flow-symlink branch September 1, 2022 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Stop symlinking flow.cylc to suite.rc?
3 participants